package com.wan.swaggerdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import springfox.documentation.oas.annotations.EnableOpenApi;
//import org.springframework.core.env.Environment;
//import org.springframework.core.env.Profiles;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
////import springfox.documentation.oas.annotations.EnableOpenApi;
//import springfox.documentation.service.ApiInfo;
////import springfox.documentation.service.Contact;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/** Swagger配置 */
@Configuration
//@EnableOpenApi
//@EnableSwagger2 // 开启Swagger2
public class SwaggerConfig {

//    @Bean
//    public Docket docket2() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("智慧厨房服务");
//    }
//
//    @Bean
//    public Docket docket3() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("生活服务");
//    }
//
//    // 配置Swagger的Docket实例
//    @Bean
//    public Docket docket(Environment environment){
//        // 设置要显示Swagger的环境
//        Profiles profiles = Profiles.of("test");
//        // 通过environment.acceptsProfiles判断是否处在自己所设的环境中
//        boolean flag = environment.acceptsProfiles(profiles);
//
//        return new Docket(DocumentationType.SWAGGER_2)
//                .apiInfo(getApiInfo())
//                .groupName("燃气服务")
//                .enable(flag)// 是否启动swagger
//                .select()
//                .apis(RequestHandlerSelectors.any())
////                .paths(PathSelectors.ant("/config/**"))
//                .build(); // 工厂模式
//    }
//
//    // 配置Swagger的信息 = apiInfo
//    public ApiInfo getApiInfo(){
//        // 作者信息
//        Contact contact = new Contact("", "", "");
//        return new ApiInfo(
//                "OpenApi在线接口文档"
//                , "接口在线管理及测试"
//                , ""
//                , ""
//                , contact
//                , ""
//                , ""
//                , new ArrayList());
//    }
}
